package com.PAT.practice01;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2021/11/17/9:11
 * @Description:
 * @Target:
 */
@SuppressWarnings("all")
public class 部分AaddB {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String s1 = scanner.next();
        String s2 = scanner.next();
        String ss1 = scanner.next();
        String ss2 = scanner.next();
        int ACount = CountNum(s1,s2);
        int BCount = CountNum(ss1,ss2);

        System.out.println(SumNumByCount(s2, ACount) + SumNumByCount(ss2, BCount));


    }


    // 编写一个统计对应数字的方法,入参字符串,字符串,出参int
    public static int CountNum(String ss,String one){
        int count = 0;
        for (int i = 0; i < ss.length(); i++) {
            if(ss.charAt(i)==one.charAt(0)){
                count++;
            }
        }
        return count;
    }


    // 依据数字及次数进行加法计算,要求,输入字符串,int的次数,输出int
    public static int SumNumByCount(String s,int count){
        int sum = 0;
        int num = s.charAt(0)-'0';
        for (int i = 0; i < count; i++) {
            sum += num * Math.pow(10,i);
        }
        return sum;
    }



}
